
<template name='score_record'>
<!-- 用户的账单查询	 -->
	<view class="box-infos font12  " >

		
		<!-- 列表区 -->
		<view class="content-box " >
			<view class="boxsss40" >
				<!-- 操作区 -->
				<view class="top-but menu-scroll-w" >
					<view class="top-but-box">
						<text selectable="true"  class="tipss">对某用户的历史积分账单进行对账</text>
						<view @click="$common.noMultipleClicks('ResetScore',ResetScore,true)" 
						class="back_color search-but" >
							<img src="../../static/img/delete.png" class="ico"></img>
							重置积分
						</view>
						
						<view @click="$common.noMultipleClicks('resDataFun',resDataFun,true)" 
						class="rightButttom" >
							<img src="../../static/img/search.png" class="ico"></img>
							刷新
						</view>
						
						
					</view>
				</view>
				<!-- end -->
				<table v-if="duizhang.resData.list &&  duizhang.resData.list.length>0">
					<!-- 表头 -->
					<thead>
						<tr >
							<th  class="centers " style="min-width: 20px;">
								序号
							</th>
							<th  >
								订单号
							</th>
							<th  class="centers ">
								商品
							</th>
							<th  class=" ">
								说明
							</th>
							<th  class=" ">
								数值
							</th>
							<th  class=" ">
								结余
							</th>
							<th  class="centers ">
								类型
							</th>
						</tr>
					</thead>
					<tbody>
						<!-- 内容 -->
						<tr  
						:key="index" @click="TabcheckedIndex=index"
						v-for="(item,index) in duizhang.resData.list" 
						:class="TabcheckedIndex == index ? 'goods-list-select':''"
						:style="(item.status==1||item.status==6) ?'color: #e40318;':''"
						>
							<td  class="centers ">
								{{index+1}}
							</td>
							<td   class="alter" @click="$common.GetOrder(item.order_id,false,2)">
								{{item.order_id}}
							</td>
							<td class="alter" @click="openGoods(item.goods.id,item.goods.name)">
								{{item.goods.name}}
							</td>
							<td   class="">
								{{item.descr}}
							</td>
							<td   class="weight" >
								{{item.score}}
							</td>
							<td   class="weight">
								{{item.end_score}}
							</td>
							
							<td  class="centers " >
								{{item.type}}
							</td>
						</tr>
					</tbody>
				</table>
				<!-- 暂无数据 -->
				<empty v-if="duizhang.resData.list &&  duizhang.resData.list.length==0"></empty>
				<!-- end -->
			</view>
			<!-- 分页 -->
			<pages 
			:sum="duizhang.page.sum"
			:current="duizhang.page.nowPage"
			@updatePage="updatePage_duizhang"
			></pages>
			<!-- end -->
		</view>
		<!-- end -->
		
		<!-- 商品页面 -->
		<uni-popup ref="pageGoods" type="center" :title="pageSend.name">
			<shopping_admin :isPop="false" :OnPageSearchGoodsId="pageSend.id"  class="h100"></shopping_admin>
		</uni-popup>
		<!-- end -->

	</view>

</template>

<script>
	import pages from "@/components/admin-components/pages.vue"
	import empty from "@/components/admin-components/empty.vue"
	export default{
		name:'score_record',
		components: {
			empty,
			pages
		},
		beforeCreate(){
			this.$options.components.shopping_admin = require('@/components/goods/goods.vue').default 
		},
		data(){
			return{
				PrintOrderData:{},//欲要打印的订单数据
				TabcheckedIndex:-1,//当前选中项
				pageSend:{//欲要传递到权限页面搜寻的内容
					id:'',//可能是user_id,goods_id
					name:''
				},
				duizhang:{
					page:{
						
						nowPage:1,//当前页数
						pageCount:1,//总页数
						maxCount:0,
						sum:0,
						pageCounts:15,
					},
					resData:{
						list:[]
					},
				}
			}
		},
		 // 此处定义传入的数据
		props: {
			OnPageUserId: '',//需要查账单的用户ID
		},
		created() {
			this.resDataFun(true)
		},
		methods:{
			/**
			 * 重置积分
			*/
			ResetScore(){
				var that  = this
				uni.showModal({
					content: '是否确定重置积分为0？此操作将会新增一条积分记录，但不清除记录。此操作不可逆！',
					success: function (res) {
						if (res.confirm) {
							that.$common.get_request(
								{
									type:'ResetScore',
									user_id:that.OnPageUserId,
								},
								(res)=>{
									that.resDataFun()
								}
							);
						}
					}
				});
			},
			/**
			 * 打开商品界面
			*/
			openGoods(goods_id,goods_name){
				this.pageSend.id = goods_id
				this.pageSend.name = goods_name
				this.$refs.pageGoods.open()
			},
			
			/**
			 * 分页器回调
			 * 
			*/
			updatePage_duizhang(pageName,pageCount){
				this.duizhang.page.nowPage = pageName
				this.duizhang.page.pageCounts = pageCount
				this.resDataFun(false)
			},
			/**
			 * 对账-获取列表
			*/
			resDataFun(isUpdatePage=true,ReqExport=0){
				var that = this
				 
				if(!that.OnPageUserId){
					that.$common.toast("未有选择需要查看的用户，请先选择后再试")
					return
				}
				that.duizhang.page.nowPage = isUpdatePage==true ? 1:that.duizhang.page.nowPage;
				that.duizhang.resData = {}
			
				that.$common.get_request(
					{
						type:'score_list',
						uid: that.OnPageUserId,
						pages:that.duizhang.page.nowPage,//当前位于页数
						page_count:that.duizhang.page.pageCounts,//当前请求页的数量
						
					},
					(res)=>{
						that.duizhang.resData = res
						that.duizhang.page.pageCount  = res.pageCount
						that.duizhang.page.sum        = res.sum
						if(isUpdatePage == true){
						that.duizhang.page.nowPage  = 1
						}
						that.duizhang.page.maxCount   = res.maxCount
					}
				);
			},
		}
	}
</script>

<style>
</style>
